package model;

import java.util.ArrayList;
public class GroupContainer
{
    private ArrayList<Group> groups;
    private static GroupContainer instance;
    
    
    public GroupContainer() {
        groups = new ArrayList<Group>();
    }
    
    public static GroupContainer getInstance() {
        if(instance == null)
        {
            instance = new GroupContainer();
        }
        return instance;
    }
    
    public void addGroup(Group group) {
        groups.add(group);
    }
    
    public Group getGroup(String groupName)
    {
        for(Group g : groups)
        {
            if(g.getGroupName().equals(groupName))
            {
                return g;
            }
        }
        return null;
    }
    
    public void deleteGroup(Group group) {
        groups.remove(group);
    }
    
    public void updateGroup(Group group, String newGroupName, double newAmountDiscount, String newPaymentType) {
        groups.get(groups.indexOf(group)).setGroupName(newGroupName);
        groups.get(groups.indexOf(group)).setAmountDiscount(newAmountDiscount);
        groups.get(groups.indexOf(group)).setPaymentType(newPaymentType);
    }
}
